package helper;

import org.achartengine.GraphicalView;
import org.achartengine.model.XYSeries;

public class GraphicalViewWrapper {

	public XYSeries currDataset;
	GraphicalView g;
	int currKey = 0;

	public GraphicalViewWrapper(GraphicalView barChartView) {
		this.g = barChartView;
	}

	public void setDataset(XYSeries xySeries) {
		this.currDataset = xySeries;
	}

	public double getYValueOfCurrentSeries(int d) {
		try {			
			int key = currDataset.getIndexForKey(d);
			int count = currDataset.getItemCount();
			if(d >= currDataset.getItemCount() + 2){
				d= (int) currDataset.getMaxX();
			}
			Double t = currDataset.getY(d);
			return t;
		} catch (Exception iex) {
			return 0.0;
		}
	}

	public GraphicalView getChart() {
		return g;
	}

	public int getIndexForKey(double d) {
		
		this.currKey = currDataset.getIndexForKey(d);
		return currKey;
	}

}
